Repository navigation
feat(privacy): enforce G13 cohort rule and cover G7, G14, G15 with tests - #21
Merged
Merged
Conversation
G13 and G15 were documented as "planned enforcement". Checking the analytics
endpoints showed G13 was not held: GET /analytics/team returned every
member's average score to any member of the organization, trainees included.
- services/privacy.py: MIN_COHORT = 5.
- GET /analytics/team: per-member stats for staff only; other members get
aggregates, and nothing but the member count when the org has fewer than 5.
- GET /risk-profile/org/{id}: a non-staff owner gets the same suppression
when fewer than 5 members have a risk profile.
- G15: regression test that a live click, a GoPhish-reported recipient and a
forwarded report leave XP, level, badges, lab results and the leaderboard
unchanged.
- G7: tests that an unknown objective fails pre-flight and that a client
cannot send a persona prompt.
- G14: index creation moved into server.ensure_indexes() so the 180-day TTL
on live_events and live_messages can be tested.
- docs: guardrails table points at the enforcing code; api.md documents the
cohort rule.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #20.
Problem
G13 (individual results only for the person and their trainer) and G15 (no live results in gamification) were listed as "planned enforcement" in
docs/guardrails.md. Checking the endpoints:GET /api/analytics/teamreturnedmember_stats(every member's average score) to any member of the organization, trainees included.GET /api/risk-profile/org/{id}returned per-principle averages to a non-staff org owner even for a two-person org, where an average identifies the other person.live_*collections), but nothing tested it.Changes
services/privacy.py:MIN_COHORT = 5,cohort_too_small()./analytics/team:member_statsfor staff only. Other members get aggregates, or{"suppressed": true}with just the member count when the org has fewer than 5 members./risk-profile/org/{id}: the same suppression for a non-staff owner when fewer than 5 members have a risk profile. Admins are unchanged.server.ensure_indexes(): index creation extracted fromlifespanso the G14 TTL indexes can be tested.tests/test_privacy_guardrails.py: G13 for both endpoints (member, small org, staff, admin), and G15. For G15, a live click, a GoPhish-reported recipient and a forwarded report leave XP, level, badges, lab results and the leaderboard unchanged.tests/test_live.py: G7 (unknown objective fails pre-flight; a client-suppliedsystem_promptis rejected) and G14 (180-day TTL onatforlive_eventsandlive_messages).api.mddocuments the cohort rule.The frontend does not call either endpoint, so there is no UI change.
Testing
pytest: 260 passedruff check/ruff format --checkclean🤖 Generated with Claude Code